// https://leetcode.cn/problems/is-subsequence/
// Created by ade on 2022/8/4.
//
#include<iostream>
#include<string>

using namespace std;

class Solution {
public:
    bool isSubsequence(string s, string t) {
        int sLen = s.size();
        int tLen = t.size();
        if (sLen > tLen || sLen == tLen && s != t) return false;
        int i = 0, j = 0;
        for (; i < sLen; i++) {
            if (s[i] == t[j]) {
                j++;
                continue;
            }
            while (j < tLen) {
                j++;
                if (s[i] == t[j]) {
                    j++;
                    break;
                }
            }
            if (j == tLen) {
                if (s[i] == t[j - 1]) {
                    i++;
                    break;
                } else
                    return false;
            }
        }
        return i == sLen;
    }
};

int main() {
    Solution so;
    string s = "abc";
    string t = "ahbgdc";
    if (so.isSubsequence(s, t))
        cout << "yes" << endl;
    else
        cout << "no";
    return 0;
}